package main

import (
	"dgo/MyProj/PrjConf"
	"dgo/goutils/utils"
	"fmt"
	"os"
	"time"
)

func main() {
	PrjConf.StartProj()
	defer PrjConf.DeferProj()

	var sb utils.BytesBuilder
	cmdLine := ""
	settingIO := 1
	if len(os.Args) < 2 {
		appConf := PrjConf.LoadConfigFromAnyWhere()
		cmdLine = appConf.AsString("cmdline", "")
		if len(cmdLine) == 0 {
			utils.Log.Warnf("没有指定cmdline")
			return
		}
		settingIO = appConf.AsInt("settingio", 1)
	} else {
		sb.AppendStrsWithSpliter(" ", os.Args[1:]...)
		cmdLine = sb.String()

	}
	utils.Log.Infof("运行命令(settingio:%d):%s\r\n", settingIO, cmdLine)

	rec := &runner_rec{}
	rec.cmdline = cmdLine
	err := rec.Start2(settingIO == 1)
	if err != nil {
		fmt.Println(err.Error())
	} else {
		rec.Wait()
	}

	utils.Log.Infof("执行完成")
	time.Sleep(time.Second * 5)
}
